<%@ page import="com.actimind.actitime.beans.UserBean,
                 com.actimind.actitime.Keys,
                 org.apache.struts.util.ResponseUtils,
                 com.actimind.actitime.beans.BillingTypeBean"%><%@ page errorPage="/error.jsp" %><%

UserBean loggedinUser = (UserBean)session.getAttribute(Keys.LOGGEDIN_USER_KEY);
BillingTypeBean type = (BillingTypeBean)session.getAttribute(Keys.BILLING_TYPE_KEY);

if (loggedinUser == null)
{
    response.sendRedirect("../login.do");
}
else if (type == null)
{
    response.sendRedirect("btlist.do");
}
else
{
%>
<%@ taglib uri="/WEB-INF/at.tld" prefix="at" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html>
<head>
    <title><bean:write name="title-prefix" scope="application"/> Edit Billing Type</title>

    <link rel="stylesheet" href="../css/at.css" type="text/css">

    <script language="JavaScript" src="../js/at.js"></script>
    <script language="JavaScript">
    function doSubmit(f)
    {
        /*if (!checkField(f.name, "Type name is empty", "isNotEmpty"))
            return false;

        trimAllTextFields(f);
        normalizeAllTextFields(f);*/

        return true;
    }
    </script>
</head>

<body bgcolor="#ffffff" topmargin="0" leftmargin="0" marginheight="0" marginwidth="0">

<jsp:include page="../top.jsp" flush="false">
    <jsp:param name="pageSection" value="administration" />
    <jsp:param name="pageAction" value="btedit" />
</jsp:include>

<html:form scope="session" action="/administration/btedit.do" method="post" onsubmit="return doSubmit(this)">

<input type="hidden" name="submitted" value="1" />

<html:hidden property="typeId" />

<table cellspacing="0" cellpadding="5" align="center" valign="top" border="0" bgcolor="#ffffff" width="770">
<tr>
    <td class="pagetitle">
        Edit Billing Type
    </td>
</tr>
<tr>
    <td align="center" class="formbuttonpane">
        <table cellspacing="0" cellpadding="3" align="center" valign="top" border="0" width="100%">
        <tr>
            <td class="formblocktitle" width="24%" nowrap="1">
                You have selected billing type:
            </td>
            <td class="formblocktitle">
                <span class="textemphasis"><%=ResponseUtils.filter(type.getName())%></span>
            </td>
            <%
            if (type.isDeletable())
            {
            %>
            <td rowspan="2" align="right">
                <input type="button" value="Delete this billing type" onclick="javascript: if (confirm('Are you sure you want to delete this billing type?')) document.location.href='<html:rewrite href='<%="btdelete.do?typeId=" + type.getId()%>'/>'" />
            </td>
            <%
            }
            %>
        </tr>
        <tr>
            <td class="formblocktitle" width="24%" nowrap="1">
                Billing type status:
            </td>
            <td class="formblocktitle">
                <%
                if (type.isInUse())
                {
                %>
                <span class="textenabled">In Use</span>
                <%
                }
                else
                {
                %>
                <span class="textinactive">Unused</span>
                <%
                }
                %>
            </td>
        </tr>
        </table>
    </td>
</tr>
<tr>
    <td class="pagetitle">
        <at:errors />
        <at:messages id="message" message="true">
            <span class="successmsg"><bean:write name="message"/></span>
        </at:messages>
    </td>
</tr>
<tr>
    <td>
        <table cellspacing="0" cellpadding="0" align="left" valign="top" border="0" bgcolor="#ffffff">
        <tr>
            <td colspan="2" class="formcomment">
                <span class="formfieldtitlereq">*</span> Indicates a required field.
            </td>
        </tr>
        <tr>
            <td colspan="2"><img height="10" width="1" src="../img/pixel.gif" /></td>
        </tr>
        <tr>
            <td colspan="2" class="formblocktitle">
                Edit Billing Type
            </td>
        </tr>
        <tr>
            <td colspan="2"><img height="10" width="1" src="../img/pixel.gif" /></td>
        </tr>
        <tr>
            <td>
                <img height="1" width="20" src="../img/pixel.gif" />
            </td>
            <td>
                <table cellspacing="0" cellpadding="3" align="left" valign="top" border="0" bgcolor="#ffffff">
                <tr>
                    <td class="formfieldtitlereq">
                        *
                    </td>
                    <td class="formfieldtitle">
                        <logic:messagesPresent property="name"><span class="errormsg">Billing Type Name:</span></logic:messagesPresent>
                        <logic:messagesNotPresent property="name">Billing Type Name:</logic:messagesNotPresent>
                    </td>
                    <td>
                        <html:text property="name" style="width: 470px" maxlength="255" size="60"/>
                    </td>
                </tr>
                </table>
            </td>
        </tr>
        <tr>
            <td colspan="2"><img height="10" width="1" src="../img/pixel.gif" /></td>
        </tr>
        </table>
    </td>
</tr>
<tr>
    <td align="center" class="formbuttonpane">
        <input type="submit" value="Save Changes" />
        <img height="1" width="100" src="../img/pixel.gif" />
        <input type="button" value="   Cancel   " onclick="if (confirm('Are you sure you want to cancel changing this billing type?')) document.location.href='<html:rewrite href='btlist.do'/>'" />
    </td>
</tr>
</table>

</html:form>

</body>
</html>
<%
}
%>